/*
TomorIT: a general data compression project aimed to be quick and efficient,
by Arpad Fekete, in Hungarian Fekete Árpád, born: Kiskunfélegyháza, 1982.04.28.
homepages: http://mathboasting.blogspot.com, http://fecowebs.ourproject.org,
motivation: Árpád aims to re-learn C++ and maybe enter the Hutter Prize,
and collaboration will be possible if the first official release is ready...

The code is shared by the MIT License:

Copyright (c) 2014 Arpad Fekete

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

--- In this file ---
The essence of the compression algorithm should be like this:
1. (optional) computation of the ruleset from the input (here be AI)
2. converting the byte stream to a stream of numbers (using the ruleset)
3. using a general algorithm to code this stream is less bits
*/
#include <iostream>
#include <fstream>
#include "ToModelSequence.cpp"

using namespace std;

int main(int argc, char* argv[]) {
    // TODO: implementation
    cout << "The essence of the compression algorithm should be like this:" << endl;
    cout << "1. (optional) computation of the ruleset from the input (here be AI)" << endl;
    cout << "2. converting the byte stream to a stream of numbers (using the ruleset)" << endl;
    cout << "3. using a general algorithm to code this stream is less bits" << endl;
    cout << "TODO: implementation..." << endl;

    // Here are only testing commands, until the program is bigger
    cout << "..." << endl;
    cout << "Here are only testing commands, until the program is bigger" << endl;

    if (argc < 2) {
        cerr << "No input file specified." << endl;
        return 1;
    }

    // we should read files in binary by default,
    // later we could auto-detect text files
    ifstream infile(argv[1], ios::in | ios::binary);
    if (!infile) {
        cerr << "Input file does not exist." << endl;
        return 1;
    }

    // ToModelSequence<char> will be one kind of output
    ToModelSequence<char> int_in = ToModelSequence<char>(infile);
    cout << "Okay! So we have a new kind of stream!" << endl;
    cout << "Let's write it to the screen at least!" << endl;
    while (true) {
        // unprofessional :-)
        char justAChar = int_in.getNext();
        if (int_in.getNextSuccess()) {
             cout << justAChar;
        } else {
             break;
        }
    }
    infile.close();
    cout << "The end." << endl;
    return 0;
}

